import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:get/get.dart';
import '../../../../entrance/route/routes.dart';
import 'state.dart';

class LoginPwdController extends GetxController {
  final state = LoginPwdState();
  @override
  void onInit() {
    super.onInit();
    state.phone = Get.arguments['phone'];
  }

  void actionForgot() {
    Get.toNamed(RouterPath.forgot_pwd);
  }

  void sure() {
    if (state.oldEditCtrl.text.isEmpty) {
      EasyLoading.showToast('请输入原密码');
      return;
    }
    if (state.newEditCtrl.text.isEmpty) {
      EasyLoading.showToast('请输入新密码');
      return;
    }
    if (state.new1EditCtrl.text.isEmpty) {
      EasyLoading.showToast('请输入确认密码');
      return;
    }
    if (state.newEditCtrl.text != state.new1EditCtrl.text) {
      EasyLoading.showToast('两次密码输入不一致');
      return;
    }
    Get.back();
  }
}
